import { api } from "@/api";
import { Card } from "antd";
import BannerPage from "@/components/page/BannerPage";
import { useEffect, useState } from "react";
import styled from "styled-components";
import LinkList from "./components/LinkList";
import AddLink from "./components/AddLink";
import Comment from "@/components/comment/Comment";

const Styled = styled.div``;

const Link = () => {
  const [loading, setLoading] = useState(true);
  let [linkList, setLinkList] = useState([]);

  useEffect(() => {
    api
      .getLinks()
      .then((res) => {
        setLinkList(res.data);
      })
      .finally(() => {
        setLoading(false);
      });
  }, []);

  return (
    <Styled>
      <BannerPage title="友链" loading={loading} label="link">
        <Card className="card-fade-up">
          {/*列表 */}
          <LinkList linkList={linkList} />
          {/* 添加 */}
          <AddLink />
          {/* 评论 */}
          <Comment type={2} />
        </Card>
      </BannerPage>
    </Styled>
  );
};

export default Link;
